<?php
	global $_W,$_GPC;
	if($_W['role']){
		$so = $_GPC['so'];
		$key = trim($_GPC['key']);
		if($so=='somemberid' && !empty($key)){
			$field = " AND u.uid = {$key} ";
		}elseif($so=='somembername' && !empty($key)){
			$field = " AND ( u.uName LIKE '%{$key}%' OR u.nickname LIKE '%{$key}%' OR m.name LIKE '%{$key}%')  ";
		}elseif($so=='somembermobile' && !empty($key)){
			$field = " AND u.uPhone = {$key} OR m.phone= {$key} ";
		}elseif($so=='somemberon' && !empty($key)){
			$field = " AND m.mcard_on = '{$key}' ";
		}
		$page = $_GPC['page'];
		$pindex = max(1, intval($page));	
		$psize = 10;
		$sql = "SELECT u.uid,u.uPhone,u.uName,u.nickname,m.name,m.phone,m.balance,m.consumption,m.mcard_on,m.activation,m.status FROM".tablename('mii_ang_user')." u LEFT JOIN ".tablename('mii_ang_mcard')." m ON u.uid = m.uid WHERE u.uniacid=:uniacid {$field} ORDER BY u.uid DESC LIMIT ".($pindex-1)*$psize.','.$psize;
		$member = pdo_fetchall($sql,array(':uniacid'=>$_W['uniacid']));
		$total = count($member,0);
		$pager = pagination($total, $pindex, $psize,$url='',$context = array('before' =>1, 'after' => 1, 'ajaxcallback' => '', 'callbackfuncname' => ''));	
		if(!empty($member)){
			include $this->template('web/member/memberlist');	
		}else{
			message('搜索会员不存在');
		}	
	}else{
		message('没有操作权限');	
	}
	function mcardNumber($uid){
		include MODULE_ROOT.'/mii/class/membercard.class.php';
		$on =  new memberNumber($uid);
		return $on->code_on();
	}
	function memberlevel($m){
		global $_W;
		include MODULE_ROOT.'/public/mcard/mcardinfo.'.$_W['uniacid'].'.php';
		$arr = $mcardinfo;
		$ac = $m;
		$islevel = $arr['islevel'];
		$df_level = array('mcard_level_level'=>$arr['mcard_level_level'],'mcard_level_name'=>$arr['default_mcard_level_name'],'mcard_level_discount'=>$arr['default_mcard_level_discount']); 
		if(empty($arr)){ return false;}
		if($islevel=='-1')
		{ 			
			return $df_level;
		 }
		if(is_array($arr['member_level_info'])){
			foreach ($arr['member_level_info'] as $key => $v) {
				if(floatval($ac) >= floatval($v['mcard_level_condition'])){
					$arrAy = array('mcard_level_level'=>$v['mcard_level_level'],'mcard_level_name'=>$v['mcard_level_name'],'mcard_level_discount'=>$v['mcard_level_discount']);
					break;
				}
			}
		}
		if($arrAy){
			return $arrAy['mcard_level_name'];
		}else{
			return $df_level['mcard_level_name'];
		}
	}	

?>